import java.util.Random;
import java.util.Scanner;//导包

/**
 * Created with Intellij IDEA.
 * Description:
 * User: Zguoxu
 * Date: 2025-02-15
 * Time: 14:02
 */
public class Test {
    public static void main(String[] args) {
        int n = -1;
        int count = 0;
        while (n != 0) {
            n &= (n - 1);
            count++;
        }
        System.out.println(count);//32
    }
    public static void main15(String[] args) {
        //1-5位水仙花数
        for (int i = 0; i < 999999; i++) {
            int count = 0;//记录位数
            int tmp = i;
            while (tmp != 0) {
                tmp /= 10;
                count++;
            }
            tmp = i;
            int sum = 0;
            while (tmp != 0) {//计算和
                sum += Math.pow(tmp % 10, count);
                tmp /= 10;
            }

            if (sum == i) {
                System.out.println(i);
            }
        }
    }
    public static void main14(String[] args) {
        for (int n = 2; n <= 100; n++) {
            int i = 0;
            for (i = 2; i < Math.sqrt(n); i++) {
                if (n % i == 0) {
                    break;
                }
            }
            if (i > Math.sqrt(n)) {
                System.out.println(n + "是素数");
            }
        }
    }
    public static void main13(String[] args) {
        //猜数字游戏
        Scanner scan = new Scanner(System.in);
        Random random = new Random();
        int randNum = random.nextInt(101);//[0,101)
        while (true) {
            System.out.println("请输入你要猜的数字:");
            int num = scan.nextInt();

            if (num < randNum) {
                System.out.println("猜小了!");
            }else if (num == randNum) {
                System.out.println("猜对了!");
                break;
            }else {
                System.out.println("猜大了!");
            }
        }
    }
    public static void main12(String[] args) {
        Scanner scan = new Scanner(System.in);
        //多次输入
        while (scan.hasNextInt()) {
            int age = scan.nextInt();

            System.out.println(age);
        }
    }
    public static void main11(String[] args) {
//        System.out.println("输出且换行");
//        System.out.print("输出不换行");
//        System.out.printf("格式化输出");
        Scanner scan = new Scanner(System.in);

        System.out.println("请输入你的年龄:");
        int age = scan.nextInt();//读一个 int 类型的整数
        System.out.println("年龄："+ age);//遇到空格或回车结束

        scan.nextLine();//帮助吃掉一个回车

        System.out.println("请输入你的姓名:");
        String name = scan.nextLine();// next 是遇到空格或回车结束，nextLine读取一行结束
        System.out.println("姓名："+ name);//会将回车读走

        System.out.println("请输入你的工资:");
        float salary = scan.nextFloat();//遇到空格或回车结束
        System.out.println("工资："+ salary);

        System.out.println("你的信息如下：");
        System.out.println("姓名: "+name+'\n'+"年龄："+age+"\n"+"工资："+salary);

        scan.close();//可以认为 scan 是一个文件资源
    }
    public static void main10(String[] args) {
        int sum = 0;
        for (int j = 1; j <= 5; j++) {
            int ret = 1;
            for (int i = 1; i <= j; i++) {
                ret *= i;
            }
            sum += ret;
        }
        System.out.println(sum);
    }
    public static void main9(String[] args) {
        int sum = 0;
        for (int i = 0; i <= 10; i++) {
            sum += i;
        }
        System.out.println(sum);
    }
    public static void main8(String[] args) {
        //求 100 ~ 200 之间，既能被 3 整除，又能被 4 整除的数字
        int num = 100;
        while (num <= 200) {
            if (num % 3 == 0 && num % 4 == 0) {
                System.out.println(num);
                num++;
                continue;
            }
            num++;
        }
    }
    public static void main7(String[] args) {
        //计算 1! + 2! + 3! + 4! + 5!
        int k = 1;
        int sum = 0;
        while (k <= 5) {
            int n = 1;
            int ret = 1;
            while (n <= k) {
                ret *= n;
                n++;
            }
            k++;
            sum += ret;
        }
        System.out.println(sum);
    }
    public static void main6(String[] args) {
        //打印 1 - 10 的数字
        int num = 1;
        while (num<=10){//while循环中参数为布尔类型
            System.out.println(num);
            num++;
        }
        /*while(true){

        }*/
        //计算 1 - 100 的和
        int sum = 0;
        while (num<=100){
            sum += num;
            num++;
        }
        System.out.println(sum);
        //计算 5 的阶乘
        int n = 1;
        int ret = 1;
        while (n<=5){
            ret *= n;
            n++;
        }
        System.out.println(ret);

    }
    public static void main5(String[] args) {
        //不能做 switch 参数的数据类型有 float double long boolean,
        //枚举，数组都可以的
        int day = 1;
        switch(day) {
            case 1:
                System.out.println("星期一");
                break;
            case 2:
                System.out.println("星期二");
                break;
            case 3:
                System.out.println("星期三");
                break;
            case 4:
                System.out.println("星期四");
                break;
            case 5:
                System.out.println("星期五");
                break;
            case 6:
                System.out.println("星期六");
                break;
            case 7:
                System.out.println("星期日");
                break;
            default:
                System.out.println("输入有误");
                break;
        }
    }
    public static void main4(String[] args) {
        //判断是否是闰年
        int year = 0;
        for ( year = 1000; year <= 2000; year++) {
            if(year%100==0){
                if(year%400==0){
                    System.out.println(year+" is leap year");
                }else{
                    System.out.println(year+" is not leap year");
                }
            }else{
                if(year%4==0){
                    System.out.println(year+" is leap year");
                }else{
                    System.out.println(year+" is not leap year");
                }
            }
        }

    }
    public static void main3(String[] args) {
        //判断一个数是正数还是负数
        int num = 10;
        if(num > 0){
            System.out.println("正数");
        }else if(num < 0){
            System.out.println("负数");
        }else{
            System.out.println("0");
        }
    }
    public static void main2(String[] args) {
        //判断一个数是奇数还是偶数
        int num = 10;
        if(num%2==0){
            System.out.println("num为偶数");
        }else{
            System.out.println("num为奇数");
        }
    }
    public static void main1(String[] args){
        int score = 92;
        if(score >= 90){// if 里是布尔表达式
        System.out.println("吃个大鸡腿!!!");
        }
    }
}
